package com.atfcm.queue;

import java.util.Arrays;
import java.util.Comparator;

public class T_973_最接近原点的K个点 {
    public int[][] kClosest(int[][] points, int k) {
        Arrays.sort(points, (a1,a2)-> {
            Double sqrt = Math.sqrt(a1[0] * a1[0] + a1[1] * a1[1]);
            Double sqrt1 = Math.sqrt(a2[0] * a2[0] + a2[1] * a2[1]);
            return Double.compare(sqrt, sqrt1);
        });

        int[][] ints = new int[k][];
        for (int i = 0; i < k; i++) {
            int[]sub = points[i];
            ints[i] = sub;
        }
        return ints;
    }

}
